Page({
  data: {

  },
  onLoad: function (options) {
    if (options.rptIndex) {
      this.setData({
        rptIndex: options.rptIndex
      })
    }
    this.setData({
      totalPrice: options.totalPrice
    })
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; //上一个页面
    var rpt_list = prevPage.data.rpt_list //取上页data里的数据也可以修改
    this.setData({
      rpt_list: rpt_list
    })
  },
  chooseRedpackage: function (e) {
    this.setData({
      rptIndex: e.detail.value
    })
  },
  comfirmRed: function () {
    console.log(this.data.rpt_list[this.data.rptIndex].rpacket_price)
    console.log(this.data.totalPrice)
    if (this.data.rpt_list[this.data.rptIndex].rpacket_price - this.data.totalPrice >= 0) {
      wx.showToast({
        title: '红包金额大于支付金额，无法使用！',
        icon: 'none'
      })
    } else {
      var pages = getCurrentPages();
      var curPages = pages[pages.length - 1];
      var prevPage = pages[pages.length - 2]; //上一个页面
      prevPage.setData({
        rptIndex: curPages.data.rptIndex
      })
      wx.navigateBack({
        delta: 1,
      })
    }

  }
})